<template>
  <div class="app-container friend-container">
    <!-- 页面标题 -->
    <el-card class="page-header-card" shadow="never">
      <div class="page-header">
        <h2 class="page-title">友情链接管理</h2>
        <p class="page-subtitle">管理系统中的友情链接信息</p>
      </div>
    </el-card>

    <!-- 搜索和操作区域合并 -->
    <el-card class="search-operation-card" shadow="hover">
      <div class="card-header">
        <h3 class="card-title">搜索与操作</h3>
      </div>
      
      <!-- 搜索区域 -->
      <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="80px" class="search-form">
        <el-row :gutter="20">
          <el-col :span="8">
            <el-form-item label="网站名称" prop="name">
              <el-input
                v-model="queryParams.name"
                placeholder="请输入网站名称"
                clearable
                @keyup.enter="handleQuery"
              />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="状态" prop="status">
              <el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
                <el-option
                  v-for="dict in friend_web_state"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <div class="search-actions">
              <el-button type="primary" icon="Search" @click="handleQuery" class="search-btn">搜索</el-button>
              <el-button icon="Refresh" @click="resetQuery" class="reset-btn">重置</el-button>
            </div>
          </el-col>
        </el-row>
      </el-form>
      
      <!-- 操作按钮区域 -->
      <div class="operation-section">
        <el-row :gutter="15" class="operation-row">
          <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="Plus"
              @click="handleAdd"
              v-hasPermi="['friend:friend:add']"
              class="operation-btn primary-btn"
            >新增</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="success"
              plain
              icon="Edit"
              :disabled="single"
              @click="handleUpdate"
              v-hasPermi="['friend:friend:edit']"
              class="operation-btn success-btn"
            >修改</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              plain
              icon="Delete"
              :disabled="multiple"
              @click="handleDelete"
              v-hasPermi="['friend:friend:remove']"
              class="operation-btn danger-btn"
            >删除</el-button>
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="warning"
              plain
              icon="Download"
              @click="handleExport"
              v-hasPermi="['friend:friend:export']"
              class="operation-btn warning-btn"
            >导出</el-button>
          </el-col>
          <div class="toolbar-wrapper">
            <right-toolbar v-model:showSearch="showSearch" @queryTable="getList" class="toolbar-right"></right-toolbar>
          </div>
        </el-row>
      </div>
    </el-card>

    <!-- 表格区域 -->
    <el-card class="table-card" shadow="hover">
      <div class="card-header">
        <h3 class="card-title">友情链接列表</h3>
        <div class="table-header-actions">
          <span class="result-count">共 {{ total }} 条记录</span>
        </div>
      </div>
      <el-table 
        v-loading="loading" 
        :data="friendList" 
        @selection-change="handleSelectionChange"
        class="friend-table"
        stripe
        highlight-current-row
        :header-cell-style="{background: '#fafafa', color: '#2d3a4f'}"
      >
        <el-table-column type="selection" width="55" align="center" />
        <!-- <el-table-column label="主键ID" align="center" prop="id" /> -->
        <el-table-column label="网站名称" align="center" prop="name" />
        <el-table-column label="网站地址" align="center" prop="url" width="180">
          <template #default="scope">
            <el-link 
              :href="scope.row.url" 
              target="_blank" 
              :underline="false"
              v-if="scope.row.url"
              class="website-link"
            >
              {{ scope.row.url }}
            </el-link>
            <span v-else>{{ scope.row.url }}</span>
          </template>
        </el-table-column>
        <el-table-column label="网站头像" align="center" prop="avatar" width="120">
          <template #default="scope">
            <el-image
              :src="scope.row.avatar"
              fit="cover"
              class="avatar-preview"
              v-if="scope.row.avatar"
              :preview-src-list="[scope.row.avatar]"
              preview-teleported
            >
              <template #error>
                <div class="image-slot" style="display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; background: #f5f7fa">
                  <el-icon><Picture /></el-icon>
                </div>
              </template>
            </el-image>
            <span v-else>无头像</span>
          </template>
        </el-table-column>
        <el-table-column label="网站描述" align="center" prop="info" min-width="200">
          <template #default="scope">
            <div class="info-cell" style="justify-content: center;">
              <span class="website-info">{{ scope.row.info }}</span>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="邮箱" align="center" prop="email" />
        <el-table-column label="排序" align="center" prop="sort" />
        <el-table-column label="状态" align="center" prop="status">
          <template #default="scope">
            <dict-tag 
              :options="friend_web_state" 
              :value="scope.row.status"
              :class="scope.row.status === 1 ? 'active-tag' : 'inactive-tag'"
            />
          </template>
        </el-table-column>
        <el-table-column label="创建时间" align="center" prop="createTime" width="120">
          <template #default="scope">
            <span class="create-time">{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="220">
          <template #default="scope">
            <div class="action-buttons">
              <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['friend:friend:edit']" class="table-action-btn edit-btn">修改</el-button>
              <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['friend:friend:remove']" class="table-action-btn delete-btn">删除</el-button>
              <el-button link type="primary" icon="Message" @click="sendEmail(scope.row)" v-hasPermi="['friend:friend:sendEmail']" class="table-action-btn email-btn">邮件</el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
      
      <pagination
        v-show="total>0"
        :total="total"
        v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize"
        @pagination="getList"
        class="pagination-container"
      />
    </el-card>
    
    <!-- 添加或修改友情链接对话框 -->
    <el-dialog  v-model="open" width="1000px" append-to-body class="friend-dialog">
      <div class="dialog-header">
        <h3 class="dialog-title">{{ title }}</h3>
      </div>
      <el-form ref="friendRef" :model="form" :rules="rules" label-width="80px" class="friend-form">
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="网站名称" prop="name">
              <el-input v-model="form.name" placeholder="请输入网站名称" class="form-input" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="网站地址" prop="url">
              <el-input v-model="form.url" placeholder="请输入网站地址" class="form-input" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="网站头像" prop="avatar">
              <div class="upload-container">
                <el-upload
                  class="avatar-uploader"
                  :http-request="customUpload"
                  :show-file-list="false"
                  :on-success="handleAvatarSuccess"
                  :before-upload="beforeAvatarUpload"
                >
                  <img v-if="form.avatar" :src="form.avatar" class="avatar" />
                  <el-icon v-else class="avatar-uploader-icon"><Plus /></el-icon>
                </el-upload>
                <div class="upload-tip">点击上传网站头像图片</div>
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="邮箱" prop="email">
              <el-input v-model="form.email" placeholder="请输入邮箱" class="form-input" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="网站描述" prop="info">
              <el-input v-model="form.info" placeholder="请输入网站描述" type="textarea" :rows="3" class="form-textarea" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="排序" prop="sort">
              <el-input-number v-model="form.sort" :min="0" controls-position="right" class="form-input-number" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="状态" prop="status">
              <el-select v-model="form.status" placeholder="请选择状态" style="width: 100%;" class="form-select">
                <el-option
                  v-for="dict in friend_web_state"
                  :key="dict.value"
                  :label="dict.label"
                  :value="parseInt(dict.value)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="下架原因" prop="reason" v-if="form.status === 0">
              <el-input v-model="form.reason" placeholder="请输入下架原因" class="form-input" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm" class="submit-btn">确 定</el-button>
          <el-button @click="cancel" class="cancel-btn">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>

  <!-- 邮件发送对话框 -->
  <el-dialog  v-model="emailOpen" width="600px" append-to-body class="email-dialog">
    <div class="dialog-header">
      <h3 class="dialog-title">发送邮件 - {{ emailForm.name }}</h3>
    </div>
    <el-form ref="emailRef" :model="emailForm" :rules="emailRules" label-width="80px" class="email-form">
      <el-form-item label="收件人" prop="to">
        <el-input v-model="emailForm.to" disabled class="form-input" />
      </el-form-item>
      <el-form-item label="主题" prop="subject">
        <el-input v-model="emailForm.subject" placeholder="请输入邮件主题" class="form-input" />
      </el-form-item>
      <el-form-item label="内容" prop="content">
        <editor 
          v-model="emailForm.content" 
          :min-height="192" 
          placeholder="请输入邮件内容" 
          class="form-editor"
        />
      </el-form-item>
    </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button type="primary" @click="submitEmail" class="submit-btn">发送</el-button>
        <el-button @click="cancelEmail" class="cancel-btn">取消</el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup name="Friend">
import { listFriend, getFriend, delFriend, addFriend, updateFriend, sendEmailApi } from "@/api/friend/friend"
import { upload }  from "@/api/systemArticle/article"
import { ElMessage } from 'element-plus'

// 添加邮件相关的响应式数据
const emailOpen = ref(false)
const emailForm = reactive({
  to: "",
  subject: "",
  content: "",
  name: ""
})

const emailRules = {
  subject: [
    { required: true, message: "邮件主题不能为空", trigger: "blur" }
  ],
  content: [
    { required: true, message: "邮件内容不能为空", trigger: "blur" }
  ]
}

/** 发送邮件按钮 */
function sendEmail(row) {
  if (!row.email) {
    proxy.$modal.msgWarning("该友情链接未设置邮箱地址")
    return
  }
  
  emailForm.to = row.email
  emailForm.name = row.name
  emailForm.subject = `友情链接通知 - ${row.name}`
  emailForm.content = `尊敬的${row.name}网站管理员：\n\n这是来自友情链接的通知邮件。`
  emailOpen.value = true

}

/** 提交邮件 */
function submitEmail() {
  proxy.$refs["emailRef"].validate(valid => {
    if (valid) {
      sendEmailApi({
        to: emailForm.to,
        subject: emailForm.subject,
        content: emailForm.content
      }).then(response => {
        if (response.code === 200) {
          proxy.$modal.msgSuccess("邮件发送成功")
          emailOpen.value = false
        } else {
          proxy.$modal.msgError("邮件发送失败: " + response.msg)
        }
      }).catch(error => {
        proxy.$modal.msgError("邮件发送失败: " + error.message)
      })
    }
  })
}

/** 取消发送邮件 */
function cancelEmail() {
  emailOpen.value = false
  proxy.resetForm("emailRef")
}

const customUpload = (options) => {
  const { file, onSuccess, onError } = options
  
  // 调用上传API
  upload(file)
    .then(response => {
      console.log('上传响应:', response)
      if (response.code === 200) { // 根据实际返回状态码调整
        // 保存返回的图片URL到表单中
        form.value.avatar =   response.data
        onSuccess(response)
        ElMessage.success('上传成功')
      } else {
        ElMessage.error(response.msg || '上传失败')
        onError(new Error(response.msg || '上传失败'))
      }
    })
    .catch(error => {
      console.error('上传错误:', error)
      ElMessage.error('上传失败: ' + (error.message || '网络错误'))
      onError(error)
    })
}

const beforeAvatarUpload = (rawFile) => {
  // if (rawFile.type !== 'image/jpeg') {
  //   ElMessage.error('Avatar picture must be JPG format!')
  //   return false
  // } else 
  if (rawFile.size / 1024 / 1024 > 5) {
    ElMessage.error('图片过大，请换一张')
    return false
  }
  return true
}

const { proxy } = getCurrentInstance()
const { friend_web_state } = proxy.useDict('friend_web_state')

const friendList = ref([])
const open = ref(false)
const loading = ref(true)
const showSearch = ref(true)
const ids = ref([])
const single = ref(true)
const multiple = ref(true)
const total = ref(0)
const title = ref("")

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    name: null,
    status: null,
  },
  rules: {
    name: [
      { required: true, message: "网站名称不能为空", trigger: "blur" }
    ],
    url: [
      { required: true, message: "网站地址不能为空", trigger: "blur" }
    ],
    info: [
      { required: true, message: "网站描述不能为空", trigger: "blur" }
    ],
    status: [
      { required: true, message: "状态不能为空", trigger: "change" }
    ],
  }
})

const { queryParams, form, rules } = toRefs(data)

/** 查询友情链接列表 */
function getList() {
  loading.value = true
  listFriend(queryParams.value).then(response => {
    friendList.value = response.rows
    total.value = response.total
    loading.value = false
  })
}

// 取消按钮
function cancel() {
  open.value = false
  reset()
}

// 表单重置
function reset() {
  form.value = {
    id: null,
    name: null,
    url: null,
    avatar: null,
    info: null,
    email: null,
    sort: null,
    reason: null,
    status: null,
    createTime: null,
    updateTime: null
  }
  proxy.resetForm("friendRef")
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1
  getList()
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef")
  handleQuery()
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.id)
  single.value = selection.length != 1
  multiple.value = !selection.length
}

/** 新增按钮操作 */
function handleAdd() {
  reset()
  open.value = true
  title.value = "添加友情链接"
}

/** 修改按钮操作 */
function handleUpdate(row) {
  reset()
  const _id = row.id || ids.value
  getFriend(_id).then(response => {
    form.value = response.data
    open.value = true
    title.value = "修改友情链接"
  })
}

/** 提交按钮 */
function submitForm() {
  proxy.$refs["friendRef"].validate(valid => {
    if (valid) {
      if (form.value.id != null) {
        updateFriend(form.value).then(response => {
          proxy.$modal.msgSuccess("修改成功")
          open.value = false
          getList()
        })
      } else {
        addFriend(form.value).then(response => {
          proxy.$modal.msgSuccess("新增成功")
          open.value = false
          getList()
        })
      }
    }
  })
}

/** 删除按钮操作 */
function handleDelete(row) {
  const _ids = row.id || ids.value
  
  // 构建友好的删除确认信息
  let confirmMessage = ''
  if (row.name) {
    // 单个删除
    confirmMessage = '是否确认删除友情链接 "' + row.name + '"'
  } else if (ids.value.length > 0) {
    // 批量删除，获取选中行的名称
    const selectedNames = []
    friendList.value.forEach(item => {
      if (ids.value.includes(item.id)) {
        selectedNames.push(item.name)
      }
    })
    
    if (selectedNames.length > 0) {
      confirmMessage = '是否确认删除友情链接 "' + selectedNames.join(', ') + '"'
    } else {
      confirmMessage = '是否确认删除友情链接编号为"' + _ids + '"的数据项？'
    }
  } else {
    confirmMessage = '是否确认删除友情链接编号为"' + _ids + '"的数据项？'
  }
  
  proxy.$modal.confirm(confirmMessage).then(function() {
    return delFriend(_ids)
  }).then(() => {
    getList()
    proxy.$modal.msgSuccess("删除成功")
  }).catch(() => {})
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download('friend/friend/export', {
    ...queryParams.value
  }, `friend_${new Date().getTime()}.xlsx`)
}

getList()
</script>

<style scoped>
.friend-container {
  background: #f0f2f5;
  padding: 20px;
  min-height: calc(100vh - 84px);
}

.page-header-card {
  margin-bottom: 20px;
  border-radius: 12px;
  border: 1px solid #e4e7ed;
  background: #ffffff;
}

.page-header {
  padding: 20px;
}

.page-title {
  font-size: 24px;
  font-weight: 600;
  color: #2d3a4f;
  margin: 0 0 10px 0;
}

.page-subtitle {
  font-size: 14px;
  color: #8492a6;
  margin: 0;
}

.search-operation-card {
  margin-bottom: 20px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  border: 1px solid #e4e7ed;
  background: #ffffff;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #e4e7ed;
  background-color: #ffffff;
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  color: #2d3a4f;
  margin: 0;
}

.search-form {
  padding: 20px;
  border-bottom: 1px solid #f0f0f0;
}

.search-actions {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  height: 100%;
  padding-top: 10px;
}

.search-btn {
  background: #409eff;
  border: none;
  color: white;
  border-radius: 6px;
  padding: 10px 20px;
  transition: all 0.3s ease;
}

.search-btn:hover {
  background: #66b1ff;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(64, 158, 255, 0.3);
}

.reset-btn {
  border-radius: 6px;
  padding: 10px 20px;
  background: #f4f4f5;
  border: 1px solid #dcdfe6;
  color: #606266;
  transition: all 0.3s ease;
}

.reset-btn:hover {
  background: #e9e9eb;
  transform: translateY(-2px);
}

.operation-section {
  padding: 20px;
}

.operation-row {
  display: flex;
  align-items: center;
}

.toolbar-wrapper {
  flex: 1;
  display: flex;
  justify-content: flex-end;
}

.operation-btn {
  border-radius: 6px;
  transition: all 0.3s ease;
  padding: 10px 15px;
  font-weight: 500;
  border: 1px solid transparent;
}

.operation-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.primary-btn {
  background: #409eff;
  color: white;
  border: none;
}

.primary-btn:hover {
  background: #66b1ff;
}

.success-btn {
  background: #67c23a;
  color: white;
  border: none;
}

.success-btn:hover {
  background: #85ce61;
}

.danger-btn {
  background: #f56c6c;
  color: white;
  border: none;
}

.danger-btn:hover {
  background: #f78989;
}

.warning-btn {
  background: #e6a23c;
  color: white;
  border: none;
}

.warning-btn:hover {
  background: #ebb563;
}

.toolbar-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.table-card {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  border: 1px solid #e4e7ed;
  background: #ffffff;
}

.table-header-actions {
  display: flex;
  align-items: center;
}

.result-count {
  font-size: 14px;
  color: #909399;
}

.friend-table {
  width: 100%;
}

.friend-table :deep(.el-table__header th) {
  background-color: #fafafa;
  color: #2d3a4f;
  font-weight: 600;
  padding: 12px 0;
}

.friend-table :deep(.el-table__row:hover) {
  background-color: #f5f7fa;
}

.website-link {
  color: #409eff;
  font-size: 13px;
  transition: color 0.3s ease;
}

.website-link:hover {
  color: #66b1ff;
  text-decoration: underline;
}

.avatar-preview {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
}

.avatar-preview:hover {
  transform: scale(1.1);
}

.info-cell {
  display: flex;
  align-items: center;
}

.website-info {
  color: #606266;
  font-size: 13px;
  line-height: 1.4;
}

.create-time {
  color: #8492a6;
  font-size: 13px;
}

.active-tag {
  background: #409eff !important;
  color: white !important;
  padding: 4px 12px !important;
  border-radius: 12px !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  border: none !important;
}

.inactive-tag {
  background: #d0d5dd !important;
  color: #606266 !important;
  padding: 4px 12px !important;
  border-radius: 12px !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  border: none !important;
}

.action-buttons {
  display: flex;
  justify-content: center;
  gap: 5px;
}

.table-action-btn {
  margin: 0 5px;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 4px;
}

.edit-btn {
  color: #409eff;
  background: #ecf5ff;
  border: 1px solid #b3d8ff;
  transition: all 0.3s ease;
}

.edit-btn:hover {
  background: #b3d8ff;
  color: #409eff;
  border-color: #409eff;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(64, 158, 255, 0.3);
}

.delete-btn {
  color: #f56c6c;
  background: #fef0f0;
  border: 1px solid #fbc4c4;
  transition: all 0.3s ease;
}

.delete-btn:hover {
  background: #fbc4c4;
  color: #f56c6c;
  border-color: #f56c6c;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(245, 108, 108, 0.3);
}

.email-btn {
  color: #67c23a;
  background: #f0f9ec;
  border: 1px solid #c2e7b0;
  transition: all 0.3s ease;
}

.email-btn:hover {
  background: #c2e7b0;
  color: #67c23a;
  border-color: #67c23a;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(103, 194, 58, 0.3);
}

.pagination-container {
  padding: 20px 0;
  display: flex;
  justify-content: center;
}

.friend-dialog {
  border-radius: 12px;
}

.dialog-header {
  padding: 15px 20px;
  border-bottom: 1px solid #e4e7ed;
  background-color: #f8f9fa;
}

.dialog-title {
  font-size: 18px;
  font-weight: 600;
  color: #2d3a4f;
  margin: 0;
}

.friend-dialog :deep(.el-dialog__header) {
  display: none;
}

.friend-form {
  padding: 20px;
}

.email-form {
  padding: 20px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
}

.form-input-number {
  width: 100%;
}

.upload-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.avatar-uploader .el-upload {
  border: 2px dashed #d9d9d9;
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: var(--el-transition-duration-fast);
  width: 178px;
  height: 178px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
}

.avatar-uploader .el-upload:hover {
  border-color: #409eff;
  background: #f0f8ff;
}

.el-icon.avatar-uploader-icon {
  font-size: 36px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar {
  width: 178px;
  height: 178px;
  display: block;
  object-fit: cover;
  border-radius: 10px;
}

.upload-tip {
  margin-top: 10px;
  font-size: 12px;
  color: #8492a6;
}

.form-editor {
  border: 1px solid #dcdfe6;
  border-radius: 6px;
  overflow: hidden;
}

.submit-btn {
  border-radius: 6px;
  padding: 12px 24px;
  background: #409eff;
  border: none;
  color: white;
  font-weight: 500;
  transition: all 0.3s ease;
}

.submit-btn:hover {
  background: #66b1ff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(64, 158, 255, 0.4);
}

.cancel-btn {
  border-radius: 6px;
  padding: 12px 24px;
  background: #f4f4f5;
  border: 1px solid #dcdfe6;
  color: #606266;
  font-weight: 500;
  transition: all 0.3s ease;
}

.cancel-btn:hover {
  background: #e9e9eb;
  transform: translateY(-2px);
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .friend-container {
    padding: 15px;
  }
  
  .search-operation-card,
  .table-card {
    padding: 15px;
  }
  
  .friend-table :deep(.el-table__column) {
    font-size: 12px;
  }
  
  .website-link,
  .website-info,
  .create-time {
    font-size: 12px;
  }
  
  .operation-row {
    flex-wrap: wrap;
  }
  
  .operation-row .el-col {
    margin-bottom: 10px;
  }
}

@media (max-width: 992px) {
  .friend-container {
    padding: 15px;
  }
  
  .search-form :deep(.el-col) {
    margin-bottom: 15px;
  }
  
  .search-actions {
    justify-content: flex-end;
  }
  
  .operation-row {
    padding: 15px 0;
  }
}

@media (max-width: 768px) {
  .friend-container {
    padding: 10px;
  }
  
  .friend-dialog {
    width: 95% !important;
    margin-top: 20px !important;
  }
  
  .email-dialog {
    width: 95% !important;
    margin-top: 20px !important;
  }
  
  .friend-form :deep(.el-col) {
    margin-bottom: 15px;
  }
  
  .card-header {
    padding: 12px 15px;
  }
  
  .card-title {
    font-size: 16px;
  }
  
  .search-form,
  .operation-section {
    padding: 15px;
  }
}
</style>
